import type { AstroIntegration } from "astro"
import modules from "./modules"
import fs from "fs/promises"

export default function (): AstroIntegration {
  return {
    name: "WikiGuideChangelogGenerate",
    hooks: {
      "astro:server:start": async () => {
        let str = ``
        await Promise.all(modules.map((m) => str = str + m() + "\n"))
        await fs.writeFile(".cache/types.d.ts", str)
      },
    }
  }
}